package weak_20241227_29.stream;

import javax.net.ssl.SSLContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Stream;

/**
 * @author zdl
 * @date 2024/12/27
 */
public class Demo21 {
    public static void main(String[] args) {
        //21. 给定两个字符串列表，合并这两个列表，并去除重复项，然后按字母顺序排序
        ArrayList<String> list1 = new ArrayList<>();
        list1.add("a");
        list1.add("b");
        list1.add("d");
        list1.add("r");
        ArrayList<String> list2 = new ArrayList<>();
        list2.add("c");
        list2.add("b");
        list2.add("e");
        list2.add("r");
        Stream<String> stream1 = list1.stream();
        Stream<String> stream2 = list2.stream();
        Stream<String> concat = Stream.concat(stream1, stream2);
        concat.distinct().sorted().forEach(s -> System.out.print(s+"\t"));
    }
}
